// const path = require('path')
const env = require('./config/env')

module.exports = {
  /*
  ** Headers of the page
  */
  head: {
    title: '易采批-管理后台',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' },
      {
        hid: 'description',
        name: 'description',
        content: '易采批'
      }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/ecp-web/favicon.ico' }
    ],
    script: [
      {
        src: `http://webapi.amap.com/maps?v=1.4.8&key=${env.amapJsKey}&plugin=AMap.ToolBar`,
        type: 'text/javascript'
      }
    ]
  },
  css: [
    'element-ui/lib/theme-chalk/index.css',
    '~/assets/sass/index.scss'
  ],
  modules: [
    '@nuxtjs/axios'
  ],
  axios: {
    headers: {
      'X-Requested-With': 'XMLHttpRequest'
    },
    proxy: true,
    prefix: '/ecp-web'
    // See https://github.com/nuxt-community/axios-module#options
  },
  proxy: {
    '/ecp-web/api': {
      target: process.env.NODE_ENV === 'pro' ? env.proProxy : env.devProxy,
      pathRewrite: {
        '^/ecp-web/api': ''
      }
    }
  },
  router: {
    base: '/ecp-web/'
  },
  plugins: [
    '~/plugins/element/element-ui',
    '~/plugins/veeValidate',
    '~/plugins/axios',
    '~/plugins/directive',
  ],
  /*
  ** Customize the progress bar color
  */
  loading: { color: '#1f8cfc' },
  /*
  ** Build configuration
  */
  build: {
    vendor: ['~/plugins/axios', 'element-ui', '~/plugins/veeValidate'],
    /*
    ** Run ESLint on save
    */
    extend(config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
    }
  }
}
